package com.iw.adoms.entity;

import com.iw.core.orm.hibernate.BaseEntity;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name = "brand")
@JsonIgnoreProperties({"new", "hibernateLazyInitializer", "department"})
public class Brand extends BaseEntity {

    private String name; // 品牌名称
    private String englishName; // 英文名称
    private String producePlace; // 产地
    private String intro; // 品牌介绍
    private String memo; // 备注
    @ManyToMany(targetEntity = Department.class, fetch = FetchType.LAZY)
    @JoinTable(name = "brand_department", joinColumns = @JoinColumn(name = "brand_id"), inverseJoinColumns = @JoinColumn(name = "department_id"))
    @Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
    private Set<Department> department; // 品牌代理商

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getEnglishName() {
        return englishName;
    }

    public void setEnglishName(String englishName) {
        this.englishName = englishName;
    }

    public String getProducePlace() {
        return producePlace;
    }

    public void setProducePlace(String producePlace) {
        this.producePlace = producePlace;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public Set<Department> getDepartment() {
        if (this.department == null) {
            this.department = new HashSet<Department>();
        }
        return department;
    }

    public void setDepartment(Set<Department> department) {
        this.department = department;
    }


}
